import java.util.Scanner;

public class text {
    public static int[] change(int[] arry) {
        int left=0,right=arry.length-1;
        while(left<right){
            while(arry[left]%2!=0&&left<right)left++;
            while(left<right&&arry[right]%2==0)right--;
            if(left<right){
                int temp=arry[left];
                arry[left]=arry[right];
                arry[right]=temp;
            }
        }
        return arry;
    }
    public static void main(String[] args) {
        //调整数组顺序使得奇数位于偶数之前。调整之后，不关心大小顺序。
        //如数组：[1,2,3,4,5,6]
        //调整后可能是：[1, 5, 3, 4, 2, 6]
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入数组大小：");
        int n=sc.nextInt();
        int[]arry=new int[n];
        for(int i=0;i<n;i++){
            arry[i]=sc.nextInt();
        }
        int[]arr=change(arry);
        System.out.print("改变后的数组：");
        for(int num:arr){
            System.out.print(num+" ");
        }
        System.out.println();
    }
}
